package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhAfterCommissionSetting;
import com.ruoyi.zsyh.service.IZsyhAfterCommissionSettingService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 售后工单提成金额设定Controller
 * 
 * @author yuexl
 * @date 2022-09-13
 */
@Controller
@RequestMapping("/zsyh/afterCommissionSetting")
public class ZsyhAfterCommissionSettingController extends BaseController
{
    private String prefix = "zsyh/afterCommissionSetting";

    @Autowired
    private IZsyhAfterCommissionSettingService zsyhAfterCommissionSettingService;

    @RequiresPermissions("zsyh:afterCommissionSetting:view")
    @GetMapping()
    public String afterCommissionSetting()
    {
        return prefix + "/afterCommissionSetting";
    }

    /**
     * 查询售后工单提成金额设定列表
     */
    @RequiresPermissions("zsyh:afterCommissionSetting:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhAfterCommissionSetting zsyhAfterCommissionSetting)
    {
        startPage();
        List<ZsyhAfterCommissionSetting> list = zsyhAfterCommissionSettingService.selectZsyhAfterCommissionSettingList(zsyhAfterCommissionSetting);
        return getDataTable(list);
    }

    /**
     * 导出售后工单提成金额设定列表
     */
    @RequiresPermissions("zsyh:afterCommissionSetting:export")
    @Log(title = "售后工单提成金额设定", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhAfterCommissionSetting zsyhAfterCommissionSetting)
    {
        List<ZsyhAfterCommissionSetting> list = zsyhAfterCommissionSettingService.selectZsyhAfterCommissionSettingList(zsyhAfterCommissionSetting);
        ExcelUtil<ZsyhAfterCommissionSetting> util = new ExcelUtil<ZsyhAfterCommissionSetting>(ZsyhAfterCommissionSetting.class);
        return util.exportExcel(list, "售后工单提成金额设定数据");
    }

    /**
     * 新增售后工单提成金额设定
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存售后工单提成金额设定
     */
    @RequiresPermissions("zsyh:afterCommissionSetting:add")
    @Log(title = "售后工单提成金额设定", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhAfterCommissionSetting zsyhAfterCommissionSetting)
    {
        return toAjax(zsyhAfterCommissionSettingService.insertZsyhAfterCommissionSetting(zsyhAfterCommissionSetting));
    }

    /**
     * 修改售后工单提成金额设定
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ZsyhAfterCommissionSetting zsyhAfterCommissionSetting = zsyhAfterCommissionSettingService.selectZsyhAfterCommissionSettingById(id);
        mmap.put("zsyhAfterCommissionSetting", zsyhAfterCommissionSetting);
        return prefix + "/edit";
    }

    /**
     * 修改保存售后工单提成金额设定
     */
    @RequiresPermissions("zsyh:afterCommissionSetting:edit")
    @Log(title = "售后工单提成金额设定", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhAfterCommissionSetting zsyhAfterCommissionSetting)
    {
        return toAjax(zsyhAfterCommissionSettingService.updateZsyhAfterCommissionSetting(zsyhAfterCommissionSetting));
    }

    /**
     * 删除售后工单提成金额设定
     */
    @RequiresPermissions("zsyh:afterCommissionSetting:remove")
    @Log(title = "售后工单提成金额设定", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhAfterCommissionSettingService.deleteZsyhAfterCommissionSettingByIds(ids));
    }
}
